#include <Kharlia/Engine/Common.h>
#include <Kharlia/Engine/Init.h>
#include <Kharlia/Engine/World.h>

namespace kharlia { namespace engine {

void _InitWorldBindings() {
    enum_<ENetMode>("ENetMode")
        .value("NM_STANDALONE", NM_STANDALONE)
        .value("NM_DEDICATED_SERVER", NM_DEDICATED_SERVER)
        .value("NM_LISTEN_SERVER", NM_LISTEN_SERVER)
        .value("NM_CLIENT", NM_CLIENT)
        .export_values()
        ;

    class_<CGame, shared_ptr<CGame>, bases<core::CObject>, noncopyable>
        ("CGameBase", init<>())
        .def_readonly("World", &CGame::mWorld)
        .def_readonly("Paused", &CGame::mPaused)
        .def_readonly("Started", &CGame::mStarted)
        .def("OnStartGame", &CGame::_OnStartGame)
        .def("OnStopGame", &CGame::_OnStopGame)
        ;

    KH_IMPL_GC(CGame);

    class_
        <CWorld, shared_ptr<CWorld>, bases<core::CObject>, boost::noncopyable>
        ("CWorldBase", init<>())
        .def("Init", &CWorld::Init)
        .def("Exit", &CWorld::Exit)
        .def("CreateLevel", &CWorld::CreateLevel)
        .def("CreateDefaultLevel", &CWorld::CreateDefaultLevel)
        .def("DestroyLevel", &CWorld::DestroyLevel)
        .def("GetLevel", &CWorld::GetLevel)
        //.def("GetActor", &CWorld::GetActor)
        .def("SetLevelClass", &CWorld::SetLevelClass).staticmethod("SetLevelClass")
        .def_readonly("Engine", &CWorld::mEngine)
        .def_readonly("Levels", &CWorld::mLevels)
        .def_readonly("LevelHashMap", &CWorld::mLevelHashMap)
        .def_readonly("DefaultLevel", &CWorld::mDefaultLevel)
        .def("StartGame", &CWorld::StartGame)
        .def("StopGame", &CWorld::StopGame)
        .def_readonly("Game", &CWorld::mGame)
        .def_readwrite("GameClass", &CWorld::mGameClass)
        // Net
        .def("NetListen", &CWorld::NetListen)
        .def("NetConnect", &CWorld::NetConnect)
        .def("NetSendDebugMessage", &CWorld::NetSendDebugMessage)
        .def("NetSendActorRPC", &CWorld::NetSendActorRPC)
        .add_property("NetIsEnabled", &CWorld::GetNetIsEnabled)
        .add_property("NetIsServer", &CWorld::GetNetIsServer)
        .add_property("NetIsClient", &CWorld::GetNetIsClient)
        .add_property("NetTickRate", &CWorld::GetNetTickRate, &CWorld::SetNetTickRate)
        .add_property("NetRepRate", &CWorld::GetNetRepRate, &CWorld::SetNetRepRate)
        .add_property("NetMode", &CWorld::GetNetMode)
        ;

    KH_IMPL_GC(CWorld);
}

}}